package com.simple.gateway.center.domian.auth.bo;

import com.simple.gateway.center.basedata.po.GatewayUser;
import com.simple.gateway.center.domian.auth.dto.GatewayUserDTO;
import com.simple.gateway.center.domian.auth.param.GatewayUserFullParam;
import lombok.Data;

/**
 * 项目: simple-gateway-core
 *
 * 功能描述: 网关应用BO
 *
 * @author: WuChengXing
 *
 * @create: 2023-08-29 23:49
 **/
@Data
public class GatewayUserBO {

    private Long id;
    /**
     * 用户id
     */
    private String userId;
    /**
     * 用户名称（对应厂商名称）
     */
    private String userName;
    /**
     * 授权类型，例如USER_TEMP_TOKEN、USER_AK
     */
    private String authType;
    /**
     * 颁发的ak
     */
    private String ak;
    /**
     * 扩展字段，建议存json格式
     */
    private String extension;

    public static GatewayUserBO param2Bo(GatewayUserFullParam gatewayUserFullParam) {
        GatewayUserBO bo = new GatewayUserBO();
        bo.setUserId(gatewayUserFullParam.getUserId());
        bo.setUserName(gatewayUserFullParam.getUserName());
        bo.setAuthType(gatewayUserFullParam.getAuthType());
        bo.setAk(gatewayUserFullParam.getAk());
        bo.setExtension(gatewayUserFullParam.getExtension());
        return bo;
    }

    public static GatewayUser bo2Do(GatewayUserBO bo) {
        GatewayUser gatewayUser = new GatewayUser();
        gatewayUser.setExtension(bo.getExtension());
        gatewayUser.setUserId(bo.getUserId());
        gatewayUser.setUserName(bo.getUserName());
        gatewayUser.setAuthType(bo.getAuthType());
        gatewayUser.setAk(bo.getAk());
        gatewayUser.setExtension(bo.getExtension());
        return gatewayUser;
    }

    public static GatewayUserDTO bo2Dto(GatewayUserBO bo) {
        GatewayUserDTO gatewayUser = new GatewayUserDTO();
        gatewayUser.setExtension(bo.getExtension());
        gatewayUser.setUserId(bo.getUserId());
        gatewayUser.setUserName(bo.getUserName());
        gatewayUser.setAuthType(bo.getAuthType());
        gatewayUser.setAk(bo.getAk());
        gatewayUser.setExtension(bo.getExtension());
        gatewayUser.setId(bo.getId());
        return gatewayUser;
    }

    public static GatewayUserBO do2Bo(GatewayUser gatewayUser) {
        GatewayUserBO bo = new GatewayUserBO();
        bo.setId(gatewayUser.getId());
        bo.setUserId(gatewayUser.getUserId());
        bo.setUserName(gatewayUser.getUserName());
        bo.setAuthType(gatewayUser.getAuthType());
        bo.setAk(gatewayUser.getAk());
        bo.setExtension(gatewayUser.getExtension());
        return bo;
    }
}
